const app = getApp();
const Controller = require('../controllers/controllers.js').controller;
Page({
  data: {
    lists:[],
    page:1,
    pageSize:10,
    isEnd:false,
    isloading:true
  },
  onLoad: function (options) {
    this.getlists()
    if(options.parentid){
      app.globalData.parentid=options.parentid
    }
  },
  getlists(source){
    Controller.mySubordinateUser({page:this.data.page,pageSize:this.data.pageSize}).then(res=>{
      if(res.data.baseData && res.data.baseData.list.length>0){
        this.setData({
          lists:this.data.lists.concat(res.data.baseData.list),
        })
      }
      if(res.data.baseData.lastPage){
        this.setData({
          isEnd:res.data.baseData.lastPage
        })
      }
      this.setData({
        isloading:false
      })
    })
  },
  onReachBottom(){
    if(this.data.isEnd){
      return
    }else{
      this.setData({
        page:this.data.page+1
      })
      this.getlists()
    }
    
  },
  onShareAppMessage: function (e) {
    let title = '';
    let imageUrl = '';
    let path=app.getCurrentPageUrlWithArgs()
    let obj = {
      title,
      imageUrl,
      path,
      success: function (res) {},
      fail(err) {}
    }
    return obj
  },
  onShareTimeline: function(res){
    let title = '';
    let imageUrl = '';
    let path=app.getCurrentPageUrlWithArgs()
    let obj = {
      title,
      imageUrl,
      path,
      success: function (res) {},
      fail(err) {}
    }
    return obj
  },
})